<?php
   $item = $_['jobdetails'];
   $lang = PFactory::getLanguage();
   $lang->load("com_jobs", JPATH_SITE, "zh-CN");
   $setup_confirm = JRequest::getString('sconfirm','');

   $thirdtools_account_info = json_decode($item->last_sync_result,true) ;
   $thirdaccount_51job = empty($thirdtools_account_info['51job']) ? null : $thirdtools_account_info['51job'];
   $thirdaccount_zhilian = empty($thirdtools_account_info['zhilian']) ? null : $thirdtools_account_info['zhilian'];
   $thirdaccount_jiancai = empty($thirdtools_account_info['jiancai']) ? null : $thirdtools_account_info['jiancai'];
   $thirdaccount_lagou = empty($thirdtools_account_info['lagou']) ? null : $thirdtools_account_info['lagou'];
   
   $syncing_51job = $syncing_zhilian = null;
   $sources = "";

   $syncing_sources = json_decode($item->syncing_sources,true) ? json_decode($item->syncing_sources,true) : null;
   if ($syncing_sources) {
      $syncing_51job = in_array('51job', $syncing_sources) ? true : false;
      $syncing_zhilian = in_array('zhilian', $syncing_sources) ? true : false;
      $syncing_jiancai = in_array('jiancai', $syncing_sources) ? true : false;
      $syncing_lagou = in_array('lagou', $syncing_sources) ? true : false;
      $sources = implode(',', $syncing_sources);
   }

 ?>
         <div id="jobdetails" class="hr_editposition" style="margin:30px 0; display:none;" data-sconfirm="<?=$setup_confirm?>" data-sources="<?=$sources?>" data-jobid="<?=$item->id?>">
            <input type="hidden" id="post_job_id" value="<?=$item->id?>">
         	<div class="hr_edittitle clearfix jobdetailsycaccount">
         	   <b>职位信息（公开）</b>
               <?php if($_['adminuser']): ?>
                  <?php if($_['edit']): ?>
         	         <a href="javascript:;" id="edit_job_position" class="medium"><img src="/images/3/greenedit.png"/> 编辑</a>
         	   
         	   <div class="pull-right" id="sync_job_position">
         	      <span class="medium">推送到：</span>
         	      <?php 
                  $sync_51job_title = '点击此处推送职位信息到前程无忧';
                  $sync_51job_text = '前程无忧';
                  $i_status_51job = '';
                  if (isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'syncing') {
                     $sync_51job_title = '正在推送到前程无忧，请稍后';
                     $sync_51job_text = '推送中... ';
                  } elseif (isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'success') {
                     if(!empty($thirdaccount_51job['uptime'])){
                        $sync_51job_title = JHtml::_('date', $thirdaccount_51job['uptime'], 'Y-m-d H:i:s') . ' 推送到前程无忧';
                        $i_status_51job = '<i class="ok"></i></a>';
                     }else{
                        $i_status_51job = '<i class=""></i>';
                     }  
                  } elseif (isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'error') {
                     $sync_51job_title = $thirdaccount_51job['msg'];
                     $i_status_51job = '<i class="notok"></i>';
                  } elseif (!isset($thirdaccount_51job['result'])){
                     $i_status_51job = '<i class=""></i>';
                  }
                  ?>
                  
                  <a href="javascript:;" class="account51job <?=(isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'syncing' ? 'unclick' : '')?>" data-placement="left" title="<?=$sync_51job_title?>" data-type="51job" data-syncaction='editjob' style="margin: 2px 7px;font-size: 12px;">
                     <?="<em>".$sync_51job_text."</em>".$i_status_51job?>
                  </a>
                  
                  <?php 
                  $sync_zhilian_title = '点击此处推送职位信息到智联招聘';
                  $sync_zhilian_text = '智联招聘';
                  $i_status_zhilian = '';
                  if (isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'syncing') {
                     $sync_zhilian_title = '正在推送到智联招聘，请稍后';
                     $sync_zhilian_text = '推送中... ';
                  } elseif (isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'success') {
                     if(!empty($thirdaccount_zhilian['uptime'])){            
                        $sync_zhilian_title = JHtml::_('date', $thirdaccount_zhilian['uptime'], 'Y-m-d H:i:s') . ' 推送到智联招聘';   
                        $i_status_zhilian = '<i class="ok"></i></a>';
                     }else{
                        $i_status_zhilian = '<i class=""></i>';
                     }               
                  } elseif (isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'error') {
                     $sync_zhilian_title = $thirdaccount_zhilian['msg'];
                     $i_status_zhilian = '<i class="notok"></i>';
                  } elseif (!isset($thirdaccount_zhilian['result'])) {
                     $i_status_zhilian = '<i class=""></i>';
                  }
                  ?>
                  
                  <a href="javascript:;" class="accountzhilian <?=(isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'syncing' ? 'unclick' : '')?>" data-placement="left" title="<?=$sync_zhilian_title?>" data-type="zhilian" data-syncaction='editjob' style="margin: 2px 7px;font-size: 12px;">
                     <?="<em>".$sync_zhilian_text."</em>".$i_status_zhilian?>
                  </a>

                  <!-- lagou -->
                  <?php 
                  $sync_lagou_title = '点击此处推送职位信息到拉勾';
                  $sync_lagou_text = '拉勾';
                  $i_status_lagou = '';
                  if (isset($thirdaccount_lagou['result']) && $thirdaccount_lagou['result'] == 'syncing') {
                     $sync_lagou_title = '正在推送到拉勾，请稍后';
                     $sync_lagou_text = '推送中... ';
                  } elseif (isset($thirdaccount_lagou['result']) && $thirdaccount_lagou['result'] == 'success') {
                     if((isset($thirdaccount_lagou['dir']) && $thirdaccount_lagou['dir'] == 'up')){
                        if(!empty($thirdaccount_lagou['uptime'])){
                           $sync_lagou_title = JHtml::_('date', $thirdaccount_lagou['uptime'], 'Y-m-d H:i:s') . ' 推送到拉勾';
                        }else{
                           $sync_lagou_title ="";
                        }
                        $i_status_lagou = '<i class="ok"></i></a>';
                     }else{
                        $i_status_lagou = '<i class=""></i>';
                     }              
                  } elseif (isset($thirdaccount_lagou['result']) && $thirdaccount_lagou['result'] == 'error') {
                     $sync_lagou_title = $thirdaccount_lagou['msg'];
                     $i_status_lagou = '<i class="notok"></i>';
                  } elseif (!isset($thirdaccount_lagou['result'])) {
                     $i_status_lagou = '<i class=""></i>';
                  }
                  ?>
                  
                  <a href="javascript:;" class="accountlagou" data-placement="left" title="<?=$sync_lagou_title?>" data-type="lagou" data-syncaction='editjob' style="margin: 2px 7px;font-size: 12px;">
                     <?="<em>".$sync_lagou_text."</em>".$i_status_lagou?>
                  </a>
                  
                  <!-- jianzuyingcai -->
                  <?php 
                  $sync_jiancai_title = '点击此处推送职位信息到建筑英才';
                  $sync_jiancai_text = '建筑英才';
                  $i_status_jiancai = '';
                  if (isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'syncing') {
                     $sync_jiancai_title = '正在推送到建筑英才，请稍后';
                     $sync_jiancai_text = '推送中... ';
                  } elseif (isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'success') {
                     if(!empty($thirdaccount_jiancai['uptime'])){    
                        $sync_jiancai_title = JHtml::_('date', $thirdaccount_jiancai['uptime'], 'Y-m-d H:i:s') . ' 推送到建筑英才';
                        $i_status_jiancai = '<i class="ok"></i></a>';
                     }else{
                        $i_status_jiancai = '<i class=""></i>';
                     }              
                  } elseif (isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'error') {
                     $sync_jiancai_title = $thirdaccount_jiancai['msg'];
                     $i_status_jiancai = '<i class="notok"></i>';
                  } elseif (!isset($thirdaccount_jiancai['result'])) {
                     $i_status_jiancai = '<i class=""></i>';
                  }
                  ?>
                  
                  <a href="javascript:;" class="accountjiancai <?=(isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'syncing'? 'unclick' : '')?>" data-placement="left" title="<?=$sync_jiancai_title?>" data-type="jiancai" data-syncaction='editjob' style="margin: 2px 7px;font-size: 12px;">
                     <?="<em>".$sync_jiancai_text."</em>".$i_status_jiancai?>
                  </a>
                  
               </div>
               <?php endif; ?>
               <?php endif; ?>
         	</div>
         	
            <div class="hr_settingwrap" id="job_position_info">
               <div class="set_quence_content">
               	<div class="form-horizontal medium clearfix">
                    <div class="control-group">
                      <label class="control-label key" for="">工作城市:</label>
                      <div class="controls">
                        <span><?php echo ($item->state || $item->city) ? ($item->state == $item->city ? $item->state : $item->state.' '.$item->city) : '不限'; ?></span>
                      </div>
                    </div>
                    <div class="control-group">
                      <label class="control-label key" for="">工作职能:</label>
                      <div class="controls">
                        <span><?php echo !empty($item->pos_txt) ? $item->pos_txt : '未设置' ; ?></span>
                      </div>
                    </div>
                    <div class="control-group">
                      <label class="control-label key" for="">工作经验:</label>
                      <div class="controls">
                        <span><?php echo $item->exp_name ? JText::_($item->exp_name) : '不限' ; ?></span>
                      </div>
                    </div>
                    <!--- 
                    <div class="control-group">
                      <label class="control-label key" for="">所属行业:</label>
                      <div class="controls">
                        <span></span>
                      </div>
                    </div>

                    <div class="control-group">
                      <label class="control-label key" for="">学历要求:</label>
                      <div class="controls">
                        <span>本科 以上</span>
                      </div>
                    </div>
                    <div class="control-group">
                      <label class="control-label key" for="">所在部门:</label>
                      <div class="controls">
                        <span>---</span>
                      </div>
                    </div>
                    -->
                    <div class="control-group">
                      <label class="control-label key" for="">月薪范围:</label>
                      <div class="controls">
                        <span><?php echo $item->salary_type ? JText::_($item->salary_type) : '不限' ; ?></span>
                      </div>
                    </div>
                    <?php if(0):?>
                    <div class="control-group">
                      <label class="control-label key" for="position">联系人:</label>
                      <div class="controls">
                        <span></span>
                      </div>
                    </div>
                    <?php endif;?>
                    <div class="control-group">
                      <label class="control-label key" for="city">招聘人数:</label>
                      <div class="controls">
                        <span><?=$item->num_needed ? $item->num_needed : '若干'; ?></span>
                      </div>
                    </div>
                    <?php if(0):?>
                    <div class="control-group">
                      <label class="control-label key" for="position">联系电话:</label>
                      <div class="controls">
                        <span></span>
                      </div>
                    </div>
                    <?php endif;?>
                  </div>
                  
                  <div class="hr_position_description medium">
                     <!-- <h6 class="normal">主要内容：</h6> -->
                     <?php
                        $item->long_desc = $item->long_desc ? htmlspecialchars_decode($item->long_desc) : $item->long_desc;
                        echo $item->long_desc ? (preg_match("/<[^<]+>/",$item->long_desc,$m) != 0 ? $item->long_desc : nl2br($item->long_desc)) : '暂无';
                     ?>
                  </div>
               </div>
            </div>
         </div>  
<div class="selectwork_listdialog purposlistbox medium" id="" style="width:310px; display:none; top:120px;"></div>
<div id="accountsetdialog_51job" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div id="accountsetdialog_zhilian" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div id="accountsetdialog_jiancai" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div id="accountsetdialog_lagou" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<?php if(!empty($_['syncto'])): ?>
<div id="popup_syncto" data-syncto="<?=$_['syncto']?>" data-addjob="<?=$_['addjob']?>"></div>
<div id="sync_now"></div>
<?php endif; ?>
